from django import template

register = template.Library()

@register.filter
def filter_status(tickets, status):
    """过滤工单列表，返回指定状态的工单"""
    return [ticket for ticket in tickets if ticket.status == status]

@register.filter
def count_status(tickets, status):
    """统计指定状态的工单数量"""
    return len([ticket for ticket in tickets if ticket.status == status])
